# -*- coding: utf-8 -*- 

###########################################################################
## Python code generated with wxFormBuilder (version Sep  8 2010)
## http://www.wxformbuilder.org/
##
## PLEASE DO "NOT" EDIT THIS FILE!
###########################################################################

import wx
import glob
import os
import LnkManage


###########################################################################
## Class LnkManage
###########################################################################

class LnkManage ( wx.Frame ):
	
	def __init__( self, parent ):
		wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"快捷管理", pos = wx.DefaultPosition, size = wx.Size( 518,482 ), style = wx.DEFAULT_FRAME_STYLE|wx.FRAME_TOOL_WINDOW|wx.TAB_TRAVERSAL )
		
		self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
		
		bSizer = wx.BoxSizer( wx.VERTICAL )
		
		self.m_panel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
		bSizer_2 = wx.BoxSizer( wx.VERTICAL )
		
		self.m_listCtrl_lnks = wx.ListCtrl( self.m_panel, wx.ID_ANY, wx.DefaultPosition, wx.Size( 500,400 ), wx.LC_REPORT )
		bSizer_2.Add( self.m_listCtrl_lnks, 0, wx.ALL, 5 )
		self.m_listCtrl_lnks.InsertColumn(0, 'name')
		self.m_listCtrl_lnks.InsertColumn(1, 'filepath')
		self.m_listCtrl_lnks.InsertColumn(2, 'lnkpath')
		
		self.m_panel.SetSizer( bSizer_2 )
		self.m_panel.Layout()
		bSizer_2.Fit( self.m_panel )
		bSizer.Add( self.m_panel, 1, wx.EXPAND |wx.ALL, 5 )
		
		bSizer_1 = wx.BoxSizer( wx.HORIZONTAL )
		
		self.m_staticTextInput = wx.StaticText( self, wx.ID_ANY, u"输入", wx.DefaultPosition, wx.DefaultSize, 0 )
		self.m_staticTextInput.Wrap( -1 )
		bSizer_1.Add( self.m_staticTextInput, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
		
		self.m_textCtrl_Input = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 150,-1 ), 0 )
		bSizer_1.Add( self.m_textCtrl_Input, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
		
		m_comboBox_dirChoices = []
		self.m_comboBox_dir = wx.ComboBox( self, wx.ID_ANY, u"Combo!", wx.DefaultPosition, wx.DefaultSize, m_comboBox_dirChoices, 0 )
		bSizer_1.Add( self.m_comboBox_dir, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
		
		self.m_btn_load = wx.Button( self, wx.ID_ANY, u"加载lnk", wx.DefaultPosition, wx.DefaultSize, 0 )
		bSizer_1.Add( self.m_btn_load, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
		
		self.m_btn_del_dir = wx.Button( self, wx.ID_ANY, u"删除目录", wx.DefaultPosition, wx.DefaultSize, 0 )
		bSizer_1.Add( self.m_btn_del_dir, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
		
		bSizer.Add( bSizer_1, 0, 0, 5 )
		
		self.SetSizer( bSizer )
		self.Layout()
		
		self.Centre( wx.BOTH )
		
		# Connect Events
		self.m_textCtrl_Input.Bind( wx.EVT_KEY_DOWN, self.m_textCtrl_InputOnKeyDown )
		self.m_comboBox_dir.Bind( wx.EVT_TEXT, self.m_comboBox_dirOnText )
		self.m_btn_load.Bind( wx.EVT_LEFT_DOWN, self.m_btn_loadOnLeftDown )
		self.m_btn_del_dir.Bind( wx.EVT_LEFT_DOWN, self.m_btn_del_dirOnLeftDown )
	
	def __del__( self ):
		self.Destroy()
		pass
	
	
	# Virtual event handlers, overide them in your derived class
	def m_textCtrl_InputOnKeyDown( self, event ):
		event.Skip()
	
	def m_comboBox_dirOnText( self, event ):
		event.Skip()

	def m_btn_loadOnLeftDown( self, event ):
		edit = ''
		edit = self.m_comboBox_dir.GetValue()
		if os.path.isdir(edit):
			for xml in glob.glob(os.path.join(edit, '*.xml')):
				lm = LnkManage.LnkManage()
				lnks = lm.loadXML(xml)
            	for lnk in lnks:
                    index = self.m_listCtrl_lnks.InsertStringItem(0, lnk[lnkManage.FILENAME])
                    self.m_listCtrl_lnks.SetStringItem(index, 1, lnk[lnkManage.FILETARGETPATH])
                    self.m_listCtrl_lnks.SetStringItem(index, 2, lnk[lnkManage.LNKPATH])
		event.Skip()

	def m_btn_del_dirOnLeftDown( self, event ):
		event.Skip()
	

if __name__ == '__main__':
    app = wx.App()
    frame = LnkManage(None)
    frame.Show()
    app.MainLoop()
